<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:include page="global.jsp"></jsp:include>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>周报查询</title>
<style type="text/css">
.ctl{
	text-decoration: none;
	color: blue;
	margin: auto 7px;
}
.ctl:HOVER{
	text-decoration: underline;
}
.center{
	text-align: center;
}
</style>
</head>
<body>
	<table id="dg" class="easyui-datagrid" title="周报查询"
			data-options="
				rownumbers:true,
				iconCls: 'icon-edit',
				singleSelect: true,
				toolbar: '#tb',
				singleSelect:true,
				pagination:true,
				fit:true,
				fitColumns:true,
				pageList:[20,25,30,35,40,45,50],
				pageSize:20
			">
		<thead>
			<tr>
				<th data-options="field:'beginDate',width:70, align:'center'">开始日期</th>				
				<th data-options="field:'endDate',width:70, align:'center'">结束日期</th>
				<th data-options="field:'workDescription',width:100, align:'center'">工作内容</th>
				<th data-options="field:'workPlan',width:80, align:'center'">工作计划</th>
				<th data-options="field:'createTime',width:70, align:'center'">填报日期</th>
				<th data-options="field:'personName',width:70, align:'center'">填报人</th>
				<th data-options="field:'id',width:90,align:'center',formatter:formatControl">查看</th>
			</tr>
		</thead>
	</table>

	<div id="tb" style="height:auto">
		
		<div>
			工作内容: <input class="easyui-textbox" type="text" id="workDescription" style="width:150px;height:25px;">						
			填报人：
			<select data-options="editable: false" id = "people" class="easyui-combobox">
				<option value = "-1"> --全部-- </option>
				<c:forEach var="item" items="${peoples }" >
					<option value = "${item.id }">${item.name }</option>
				</c:forEach>
			</select>
			填报日期：<input class="easyui-datebox"  id="createTimeBegin" style="width:150px;height:25px;">
			至  <input class="easyui-datebox"  id="createTimeEnd" style="width:150px;height:25px;">
			
			<a href="javascript:search()" class="easyui-linkbutton" iconCls="icon-search">查 找</a>
		</div>
	</div>
	
	<div id="lookDetail" class="easyui-window" title="周报详情" data-options="modal:true,closed:true,iconCls:'icon-search'" style="width:570px; height:450px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<table width="100%" height="100%">
					<tr>
						<td align="right">开始日期：</td>
						<td>
							<input class="easyui-datebox" id="lookBeginDate" style="width: 150px;" readonly="readonly">
						</td>
						<td align="right">结束日期：</td>
						<td>
							<input class="easyui-datebox" id="lookEndDate" style="width: 150px;" readonly="readonly">
						</td>
					</tr>
					<tr>
						<td align="right">填报日期：</td>
						<td>
							<input class="easyui-datebox" id="lookCreateTime" style="width: 150px;" readonly="readonly">
						</td>					
										
					 	<td align="right">填报人：</td>
						<td>
							<input class="easyui-textbox" id="lookPersonId" style="width: 150px;" readonly="readonly" />
						</td>
					</tr>
					
					<tr>
						<td align="right">工作内容：</td>
						<td colspan="3">
							<input class="easyui-textbox" id="lookWorkDescription" style="width: 435px; height: 140px;" data-options="multiline:true" readonly="readonly" />
						</td>
					</tr>
					
					<tr>
						<td align="right">工作计划：</td>
						<td colspan="3">
							<input class="easyui-textbox" id="lookWorkPlan" style="width: 435px; height: 120px;" data-options="multiline:true" readonly="readonly" />
						</td>
					</tr>
					
				</table>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:$('#lookDetail').window('close')" style="width:80px">关 闭</a>
			</div>
		</div>
	</div>
	
	<script type="text/javascript">
		function formatControl(val, row){
			return '<a class="ctl" href="javascript:void(0)" onclick="lookDetail(' + val + ')">基本信息</a>';
		}
		function search(){
			var people = $("#people").combobox("getValue");
			var workDescription = $("#workDescription").textbox("getValue").trim();			
			var createTimeBegin = $("#createTimeBegin").textbox("getValue").trim();
			var createTimeEnd = $("#createTimeEnd").textbox("getValue").trim();
			var url = "queryPersonWeeklyReport?workDescription="+workDescription+"&personId="+people+ "&createTimeBegin=" + createTimeBegin+ "&createTimeEnd=" + createTimeEnd;
			$("#dg").datagrid('reload', url);
		}
		function lookDetail(id){
			var params = "id=" + id;
			$.ajax({
				type: "GET",
			  	url: "findOnePersonWeeklyReport",
			  	data: params,
			  	success:function(data){
					var val = $.parseJSON(data);
					if(val.success){
						var item = val.data;
						
						$("#lookPersonId").textbox("setValue", item.personName);
						$("#lookWorkDescription").textbox("setValue", item.workDescription);
						$("#lookWorkPlan").textbox("setValue", item.workPlan);
						$("#lookBeginDate").textbox("setValue", item.beginDate);
						$("#lookEndDate").textbox("setValue", item.endDate);
						$("#lookCreateTime").textbox("setValue", item.createTime);
						
						$('#lookDetail').window('open');
					}else{
						$.messager.alert("提示", val.msg, "error");
					}
			  	}
			});
		}
		$(function(){
			search();
		});
	</script>
</body>
</html>